package org.objective.dal.saver;

import org.common.service.ServiceRegister;
import org.objective.base.BaseFieldInfo;
import org.objective.base.BaseObjectInfo;
import org.objective.base.BaseTypeInfo;
import org.objective.command.AuthToken;
import org.objective.command.Command;
import org.objective.dal.commands.InsertObjectCommand;
import org.objective.dal.commands.InsertTypeCommand;
import org.objective.service.Saver;

/**
 *
 * @author gus
 */
class SaverImplement implements Saver
{
    private ServiceRegister register;

    SaverImplement(ServiceRegister instance)
    {
        this.register = instance;
    }

    @Override
    public void insertObject(BaseObjectInfo objectInfo) throws Exception
    {
        Command cmd = new InsertObjectCommand(objectInfo);
        cmd.execute(register, new AuthToken());
    }

    @Override
    public void deleteObject(long id)
    {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void insertType(BaseTypeInfo typeInfo) throws Exception
    {
        Command cmd = new InsertTypeCommand(typeInfo);
        cmd.execute(register, new AuthToken());
    }

    @Override
    public void updateType(BaseTypeInfo typeInfo)
    {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void deleteType(long id)
    {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void deleteField(long id)
    {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void insertField(BaseFieldInfo fieldInfo)
    {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void updateField(BaseFieldInfo fieldInfo)
    {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}
